import networkx as nx
import matplotlib.pyplot as plt
import random
G = nx.DiGraph()

G.add_nodes_from(list(range(11)))
G.add_edge(0, 1, capacity = 1e9, weight = 0)
G.add_edge(0, 2, capacity = 1e9, weight = 0)
G.add_edge(1, 5, capacity = 1e9, weight = 1)
G.add_edge(2, 3, capacity = 1e9, weight = 1)
G.add_edge(3, 4, capacity = 1e9, weight = 1)
G.add_edge(4, 6, capacity = 1e9, weight = 0)
G.add_edge(4, 7, capacity = 1e9, weight = 0)
G.add_edge(6, 5, capacity = 1e9, weight = 0)
G.add_edge(5, 8, capacity = 1e9, weight = 0)
G.add_edge(7, 9, capacity = 1e9, weight = 0)
G.add_edge(8, 10, capacity = 1, weight = 0)
G.add_edge(9, 10, capacity = 1, weight = 0)
#nx.draw_networkx(G)
#plt.show()
print (nx.max_flow_min_cost(G, 0, 10))
#print (set(dict(nx.shortest_path_length(G, target='E'))))